home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The 640 MEG Shareware Studio 2
/
The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO
/
clang
/
nn.zip
/
DB.H
< prev
next >
Wrap
C/C++ Source or Header
|
1989-06-28
|
3KB
|
102 lines
/*
* DATABASE ORGANIZATION:
*
* The central nn information is contained in following files:
* DB_DIRECTORY/MASTER
* DB_DIRECTORY/GROUPS
* DB_DIRECTORY/DATA/nnn.x
* DB_DIRECTORY/DATA/nnn.d
*
* The MASTER file consists of a header and one entry for each news
* group. The sequence of the group headers defines the group
* number associated with the group.
*
* The GROUPS file contains the names of the news groups; the names
* occur in the same sequence as in the MASTER file.
*
* For each news group, the DATA directory contains two files whose
* name is constructed from the group number 'nnn':
*
* nnn.x Index file
* nnn.d Data file
*
* The index file provides a a mapping from article numbers to offsets
* in the data file.
*
* The data file contains the actual header data. Each article is
* represented by a Header, an array of Cross Postings, and the
* strings representing the sender name and the article subject:
*
* header
* group_number 1 [ if cross posted ]
* group_number 2
* ...
* sender name (null terminated) [if sender_length > 0]
* subject (null terminated) [if subject_length > 0]
*
* For a digest, cross posted groups are only specified for first
* the entry.
*
* The format of the MASTER file is specifed in the data.h
* file. The format of the index and data files are specified below.
*
* Unless NETWORK_DATABASE is defined, the database will
* will contain machine dependent binary data.
*/
typedef struct {
off_t data_offset;
} index_entry;
typedef struct {
article_number dh_number;
time_stamp dh_date; /* encoded Date: filed (not a time_t value!!) */
off_t dh_hpos; /* absolute offset for first byte of header */
off_t dh_lpos; /* absolute offset for last byte of article */
int16 dh_fpos; /* relative offset for first byte in article text */
int16 dh_lines;
int8 dh_replies;
int8 dh_cross_postings;
int8 dh_subject_length;
int8 dh_sender_length;
} data_header;
/*
* The article_number is negative for digest article header and
* zero for following sub articles.
*/
article_number current_digest_article;
#define IS_DIGEST_HEADER(e1) \
((e1).dh_number < 0 && (current_digest_article = -((e1).dh_number)))
#define IS_SUB_DIGEST(e1) \
(((e1).dh_number) == 0)
#define ARTICLE_NUMBER(e1) \
(((e1).dh_number <= 0) ? current_digest_article : ((e1).dh_number))
#ifdef NETWORK_DATABASE
typedef int32 cross_post_number;
#else
typedef group_number cross_post_number;
#endif
/* open database files */
FILE *open_groups(), *open_data_file();
/* data access */
off_t get_index_offset(), get_data_offset();